% Save results
% True IRFs
Results.the_true_irf=the_true_irf;
Results.the_rms_irf=the_rms_irf;

% Criteria
Results.RMSE_result=RMSE_result_plot;
Results.BIAS_result=BIAS_result_plot;
Results.STD_result=STD_result_plot;

% Coverage rate
Results.CV.VAR.seqblock=CVG_var_seqblock_avg_across;
Results.CV.VAR.bootrep=CVG_var_bootrep_avg_across;
Results.CV.LP.seqblock=CVG_lp_seqblock_avg_across;
Results.CV.LP.bootrep=CVG_lp_bootrep_avg_across;
Results.CV.Pool.seqblock=CVG_pool_seqblock_avg_across;
Results.CV.Pool.seqblock_bs1=CVG_pool_seqblock_avg_across_bs1;
Results.CV.Pool.seqblock_bs2=CVG_pool_seqblock_avg_across_bs2;
Results.CV.Pool.bootrep=CVG_pool_bootrep_avg_across;

% Average length
Results.AL.VAR.seqblock=IRF_VAR_seqblock_avglength_acrossspec;
Results.AL.VAR.bootrep=IRF_VAR_bootrep_avglength_acrossspec;
Results.AL.LP.seqblock=IRF_LP_seqblock_avglength_acrossspec;
Results.AL.LP.bootrep=IRF_LP_bootrep_avglength_acrossspec;
Results.AL.Pool.seqblock=IRF_Pool_seqblock_avglength_acrossspec;
Results.AL.Pool.seqblock_bs1=IRF_Pool_seqblock_avglength_acrossspec_bs1;
Results.AL.Pool.seqblock_bs2=IRF_Pool_seqblock_avglength_acrossspec_bs2;
Results.AL.Pool.bootrep=IRF_Pool_bootrep_avglength_acrossspec;

% Correlation
Results.COR_VARLP_seqblock=correlation_varlp_seqblock_save;
Results.COR_VARLP_seqblock_bs1=correlation_varlp_seqblock_save_bs1;
Results.COR_VARLP_seqblock_bs2=correlation_varlp_seqblock_save_bs2;
Results.COR_VARLP_bootrep=correlation_varlp_bootrep_save;

% Saving results
if strcmp(estimand_type, 'ObsShock')==1
    if Interested_variable==21
        if lag_type ==2
     Simulation_results = fullfile(spath, 'DFMDGP_IPObsLag2.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==1
     Simulation_results = fullfile(spath, 'DFMDGP_IPObsLag1.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==4
     Simulation_results = fullfile(spath, 'DFMDGP_IPObsLag4.mat');
     save(Simulation_results, 'Results');
        end

    elseif Interested_variable==56
        if lag_type ==2
     Simulation_results = fullfile(spath, 'DFMDGP_UnemObsLag2.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==1
     Simulation_results = fullfile(spath, 'DFMDGP_UnemObsLag1.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==4
     Simulation_results = fullfile(spath, 'DFMDGP_UnemObsLag4.mat');
     save(Simulation_results, 'Results');
        end
    end

elseif strcmp(estimand_type, 'IV')==1
     if Interested_variable==21
        if lag_type ==2
     Simulation_results = fullfile(spath, 'DFMDGP_IPIVLag2.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==1
     Simulation_results = fullfile(spath, 'DFMDGP_IPIVLag1.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==4
     Simulation_results = fullfile(spath, 'DFMDGP_IPIVLag4.mat');
     save(Simulation_results, 'Results');
        end

    elseif Interested_variable==56
        if lag_type ==2
     Simulation_results = fullfile(spath, 'DFMDGP_UnemIVLag2.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==1
     Simulation_results = fullfile(spath, 'DFMDGP_UnemIVLag1.mat');
     save(Simulation_results, 'Results');
        elseif lag_type ==4
     Simulation_results = fullfile(spath, 'DFMDGP_UnemIVLag4.mat');
     save(Simulation_results, 'Results');
        end
     end
end